package com.tledu.springbootmybatis.core;

import com.tledu.springbootmybatis.core.exception.CustomException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author cyrus
 */
@ControllerAdvice
public class HandleExceptionController {

    @ResponseBody
    @ExceptionHandler(CustomException.class)
    public AjaxResult<String> handleCustomException(CustomException exception) {
        return new AjaxResult<>(500, exception.getMessage());
    }

}
